#define _CRT_SECURE_NO_WARNINGS 1
class Solution {
public:
    vector<int> diStringMatch(string s) {
        int left = 0, right = s.size(), n = s.size();
        vector<int> ret(n + 1);
        for (int i = 0; i < n; i++)
        {
            if (s[i] == 'I') ret[i] = left++;
            else ret[i] = right--;
        }
        ret[n] = left;
        return ret;
    }
};